package org.smoozik.app.mode.rythmtrainer;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;

import org.smoozik.app.ihm.Constants;

public class RythmTrainerListener implements ActionListener {
	RythmTrainerMode mode;

	public RythmTrainerListener(RythmTrainerMode mode) {
		super();
		this.mode = mode;
	}

	public void actionPerformed(ActionEvent e) {
		mode.getPanel().requestFocusInWindow();

		Object source = e.getSource();
		if (source instanceof JButton) {
			JButton button = (JButton) source;
			String labelButton = button.getText();
			if (Constants.PLAY_LABEL.equals(labelButton)) {
				mode.start();
			} else if (Constants.PAUSE_LABEL.equals(labelButton)) {
				mode.pauseTimer();
			} else if (Constants.STOP_LABEL.equals(labelButton)) {
				mode.stopTimer();
			} else if (Constants.OPEN_LABEL.equals(labelButton)) {
				mode.open();
			} else if (Constants.RELOAD_LABEL.equals(labelButton)) {
				mode.reload();
			} else if (Constants.GEN_LABEL.equals(labelButton)) {
				mode.genSong();
			} else if (Constants.SAVE_LABEL.equals(labelButton)) {
				mode.save();
			} else if (Constants.REC_LABEL.equals(labelButton)) {
				mode.rec();
			} else if (Constants.DONE_LABEL.equals(labelButton)) {
				mode.done();
			} else if (Constants.SELECT_LABEL.equals(labelButton)) {

			} else if (Constants.GO_LABEL.equals(labelButton)) {

			}
		}
	}

}
